package com.gcsoftware.utils.mail;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mail.javamail.JavaMailSender;

import javax.mail.internet.MimeMessage;

/**
 * Created by qs on 2018/3/27.
 */
public class SendMailTask extends Thread {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    private JavaMailSender sender;
    private MimeMessage message;
    private long startTime;
    public SendMailTask(JavaMailSender sender, MimeMessage message , long startTime) {
        this.message = message;
        this.sender = sender;
        this.startTime = startTime;
    }
    @Override
    public void run() {
        sender.send(message);
        logger.info("Send email success, cost {} million seconds", System.currentTimeMillis() - startTime);
    }
}
